<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>

    //声明两个promise对象
    const p1 = new Promise((resolve, reject) => {
      setTimeout(() => {
        resolve('商品数据 － 1');
      }, 1000)
    });

    const p2 = new Promise((resolve, reject) => {
      setTimeout(() => {
        reject('出错啦');
      }, 1000)
    });

    //调用 allsettled 方法，只要有 1 个对象成功状态，就是成功状态
    const result = Promise.allSettled([p1, p2]);
    console.log(result);

    // 调用 all 方法  只要有 1 个对象失败状态，就是失败状态
    const result2 = Promise.all([p1, p2]);
    console.log(result2);



  </script>
</body>

</html>